<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2025/5/14
  Time: 14:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <title>发布商品</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link type="text/css" rel="stylesheet" href="css/base.css">
    <link type="text/css" rel="stylesheet" href="css/common.css">
    <link type="text/css" rel="stylesheet" href="css/index.css">
    <script type="text/javascript" src="js/goods.js" defer></script>
    <script type="text/javascript" src="js/index.js" defer></script>
</head>
<body>

<%--导入导航栏header效果--%>
<jsp:include page="header.jsp">
  <jsp:param name="flag" value="5"/>
</jsp:include>

<%--商品发布模块--%>
<div class="container">
    <c:if test="${!empty gas}">
        <div class="publish-success" id="publishSuccess">${gas}</div>
    </c:if>
    <c:if test="${!empty failgas}">
        <div class="publish-success" id="publishSuccess">${failgas }</div>
    </c:if>

    <form class="publish-form" action="/goods_publish" method="post" enctype="multipart/form-data" >
        <div class="form-group">
            <label for="goodsName">商品名称</label>
            <input type="text" id="goodsName" name="goodsName" required>
            <div class="error" id="nameError"></div>
        </div>

        <div class="form-group">
            <label for="goodsDetail">商品描述</label>
            <textarea id="goodsDetail" rows="5" name="goodsDetail" required></textarea>
            <div class="error" id="detailError"></div>
        </div>

        <div class="form-group">
            <label for="old-level">新旧程度</label>
            <select id="old-level" name="old-level" required>
                <option value="">请选择</option>
                <option value="10">全新</option>
                <option value="9">九成新</option>
                <option value="8">八成新</option>
                <option value="7">七成新</option>
                <option value="6">六成新</option>
                <option value="5">五成新</option>
                <option value="4">四成新</option>
                <option value="3">三成新</option>
                <option value="2">二成新</option>
                <option value="1">一成新</option>
            </select>
        </div>

<%--        商品类型需要调取数据库的内容--%>
        <div class="form-group">
            <label for="category">商品类别</label>
            <select id="category" name="category_id" required>
                <option value="">请选择</option>
                <c:forEach items="${categoryList}" var="t">
                    <option value="${t.id}">${t.name}</option>
                </c:forEach>
            </select>
        </div>


        <div class="form-group">
            <label for="inventory">库存数量</label>
            <input type="number" id="inventory" min="1" value="1" name="inventory" required>
        </div>

        <div class="form-group">
            <label for="price">商品价格</label>
            <input type="number" id="price" min="0.00" step="0.01" name="price" required>
        </div>

        <div class="form-group">
            <label>是否支持砍价</label>
            <input type="radio" name="is_bargain" value="1" checked>支持砍价
            <input type="radio" name="is_bargain" value="0" >不支持砍价
        </div>

        <div class="form-group">
            <label>上传商品图片</label>
            <span class="prompt-message">*最多可上传3张图片</span><br><br>
<%--            实现上传1-3张图片的预览和删除操作--%>
            <div class="image-uploader">
                <div class="images-preview-group">
                    <div class="images-preview">
                        <span class="plus-icon">+</span>
                    </div>
                    <input type="file" id="goodsImages1" accept="image/*" name="goodsImages1" required>
                    <button class="delete-Btn" data-index="1">×</button>
                </div>
                <div class="images-preview-group">
                    <div class="images-preview">
                        <span class="plus-icon">+</span>
                    </div>
                    <input type="file" id="goodsImages2" accept="image/*" name="goodsImages2">
                    <button class="delete-Btn" data-index="2">×</button>
                </div>
                <div class="images-preview-group">
                    <div class="images-preview">
                        <span class="plus-icon">+</span>
                    </div>
                    <input type="file" id="goodsImages3" accept="image/*" name="goodsImages3">
                    <button class="delete-Btn" data-index="3">×</button>
                </div>
            </div>
            <div class="error" id="imageError"></div>
        </div>

        <button type="submit" class="goods-publish-btn">发 布 商 品</button>
    </form>
</div>


<%--footer模块--%>
<jsp:include page="footer.jsp"></jsp:include>


</body>
</html>
